package com.snake.springboot.authority.service.assembler;

import com.snake.springboot.authority.api.model.AuthRoleModel;
import com.snake.springboot.authority.dao.mybatis.entity.AuthRoleDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.utils.PropertyUtils;

/**
 * 类 {@code AuthRoleAssembler}  <br> .
 * <p>详细描述
 * 创建时间：2024/5/27 14:50
 *
 * @author Yzhui
 * @see
 */
public class AuthRoleAssembler {

    public static AuthRoleDO assembleAuthRoleDO(AuthRoleModel model, boolean isNew) throws Exception {
        AuthRoleDO entity = new AuthRoleDO();
        PropertyUtils.copyPropertiesIfNull(entity, model);
        if (isNew) {
            SerialNumberGeneratorFactory.buildId4Bean(entity, "roleId");
        }
        return entity;
    }

    public static AuthRoleModel assembleAuthRoleModel(AuthRoleDO entity) {
        AuthRoleModel model = new AuthRoleModel();
        PropertyUtils.copyPropertiesIfNull(model, entity);
        return model;
    }

}
